package xkp.lesson.dao;

import xkp.lesson.db.DBConnection;
import xkp.lesson.entity.StuInfoEntity;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class StuInfoDao implements BaseDao<StuInfoEntity> {
    @Override
    public List<StuInfoEntity> selectAll() throws SQLException {
        //要习惯使用父类引用指向子类对象---- 有一定的好处
        List<StuInfoEntity> list = new ArrayList<>();
        Connection connection = DBConnection.getConnection();
       /* String sql = "SELECT stu_id,stu_name,stu_age,stu_sex,class_name FROM stu_info " +
                "LEFT JOIN class_info ON stu_info.`class_id` = class_info.`class_id`;";*/
       String sql = "select * from view_stu_class";
       //按照字段对应即可
        connection.close();
        return list;
    }

    @Override
    public StuInfoEntity selectById(Integer id) throws SQLException {
        return null;
    }

    @Override
    public boolean insert(StuInfoEntity stuInfoEntity) throws SQLException {
        return false;
    }

    @Override
    public boolean deleteById(Integer id) throws SQLException {
        return false;
    }

    @Override
    public boolean update(StuInfoEntity stuInfoEntity) throws SQLException {
        return false;
    }
}
